
<?php
$items_per_group = 5;
$total_records=$post_record->row()->t_records;
$total_groups = ceil($total_records/$items_per_group);

$uri = $this->uri->segment(3);
$uir_con = $this->uri->segment(3)==""?1:0;
?>
	<script type="text/javascript">
$(document).ready(function() {
	var uri = <?php echo $uir_con; ?>;
	var track_load = 0; //total loaded record group(s)
	var loading  = false; //to prevents multipal ajax loads
	var total_groups = <?php echo $total_groups; ?>; //total record group(s)
	if(total_groups==0){
		$("#results").html(
		'<p style="padding:25px; text-align:center; color:#000; font-size:18px; line-height:45px;">'
+"គ្មានទិន្នន័យទេ។​<br /> បើសិនជាលោកអ្នកមានចម្ងល់ទាក់ទងនិងគេហទំព័ររបស់យើងសូមទំនាក់ទំនងតាមរយះ អាស័យដ្ឋានខាងក្រោម ​:"+
'<br /><a>www.xxxxxx@xxxxx.com</a><p>');
	}else if(uri==1){
		$("#results").html(
		'<p style="padding:25px; text-align:center; color:#000; font-size:18px; line-height:45px;">'
+"គ្មានទិន្នន័យទេ។​<br /> បើសិនជាលោកអ្នកមានចម្ងល់ទាក់ទងនិងគេហទំព័ររបស់យើងសូមទំនាក់ទំនងតាមរយះ អាស័យដ្ឋានខាងក្រោម ​:"+
'<br /><a>www.xxxxxx@xxxxx.com</a><p>');
	}else{
		$('#results').load("<?php echo site_url('tags/get_data_by_tag_ajax');?>", {'group_no':track_load,'uri_id':"<?php echo $uri; ?>"}, function( ) {
		track_load++;  
	}); //load first group
	
	$(window).scroll(function() { //detect page scroll
		if($(window).scrollTop() + $(window).height() == $(document).height())  //user scrolled to bottom of the page?
		{
			
			if(track_load <= total_groups && loading==false) //there's more data to load
			{
				loading = true; //prevent further ajax loading
				$('.animation_image').show(); //show loading image
				//load data from the server using a HTTP POST request
				$.post('<?php echo site_url('tags/get_data_by_tag_ajax');?>',{'group_no': track_load,'uri_id':"<?php echo $uri; ?>"}, function(data){
								
					$("#results").append(data); //append received data into the element

					//hide loading image
					$('.animation_image').hide(); //hide loading image once data is received
					
					track_load++; //loaded group increment
					loading = false; 
				
				}).fail(function(xhr, ajaxOptions, thrownError) { //any errors?
					
					alert(thrownError); //alert with HTTP error
					$('.animation_image').hide(); //hide loading image
					loading = false;
				
				});
				
			}
		}
	});
	}
});
</script>
<!-- / end load ajax page -->
<section id="content">
	<!-- Docs page layout -->
	<div id="container" class="transitions-enabled infinite-scroll clearfix">
		<div id="results">
				
		</div>
	</div>
	<!-- #container -->
	<nav id="page-nav">
		
	</nav>
	<div class="animation_image" style="display:none" align="center"><img src="<?php echo base_url().F_IMG; ?>ajax-loader.gif"></div>
</section>


			